﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CRM.BLL;
using DP.Web.UI;

using System.Text;
using CRM.Entity;

using DP.Web.UI.Controls;
using DP.Common;

namespace CRM.Web
{
    public partial class Bottom : Common.PageBase
    {
        /// <summary>
        /// 
        /// </summary>
        T_REPAIRCASE_BLL repairCaseBll = new T_REPAIRCASE_BLL();
        /// <summary>
        /// 
        /// </summary>
        T_CONSULTINGCASE_BLL consultingCaseBll = new T_CONSULTINGCASE_BLL();
        /// <summary>
        /// 
        /// </summary>
        T_COMPLAINTCASE_BLL complaintCaseBll = new T_COMPLAINTCASE_BLL();
        /// <summary>
        /// 
        /// </summary>
        T_VOICEMAIL_BLL voiceMailBll = new T_VOICEMAIL_BLL();
        /// <summary>
        /// 
        /// </summary>
        T_CALLLOSS_BLL callLossBll = new T_CALLLOSS_BLL();

        /// <summary>
        /// 
        /// </summary>
        T_CONTENTAUTHORITY_BLL caBll = new T_CONTENTAUTHORITY_BLL();
        /// <summary>
        /// 
        /// </summary>
        T_ROLEORDERSTATUSAUTHORITY_BLL roleOrderStatusAuthorityBll = new T_ROLEORDERSTATUSAUTHORITY_BLL();


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pageInit();
            }
           
        }

        private void pageInit()
        {
            long RepairCaseCount = repairCaseBll.GetCount(GenerationRepairCaseSQLString().ToString());
            long ConsultingCaseCount = consultingCaseBll.GetCount(GenerationConsultingCaseSQLString().ToString());
            long ComplaintCaseCont = complaintCaseBll.GetCount(GenerationComplaintCaseSQLString().ToString());
            long VoiceMailCount = voiceMailBll.GetCount(GenerationVoiceMailSQLString().ToString());
            long CallLossCount = callLossBll.GetCount(GenerationLostCallSQLString().ToString());

            string msg = "您现在有待处理：投诉工单 （{0}） 条、报修工单 （{1}） 条、咨询工单 （{2}） 条、待办呼损 （{3}） 条、待办留言 （{4}） 条。";

            marq.InnerText = String.Format(msg, ComplaintCaseCont, RepairCaseCount, ConsultingCaseCount, CallLossCount, VoiceMailCount);
            //string _Ext = PageHelper.GetQueryString(this.Page, "EXT");
            //string _SeatID = PageHelper.GetQueryString(this.Page, "SEATID");
            //UserLoginInfo info = UserLoginInfo.GetLoginInfo();
            //lblDepartmentName.Text = info.DepartmentEntity.DEPARTMENTNAME;
            //lblExt.Text = _Ext;
            //lblLoginName.Text = info.UserEntity.LOGINNAME;
            //lblLoginTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //lblRole.Text = info.RoleEntity.ROLENAME;
            //lblSeatID.Text = _SeatID;
            //lblUserName.Text = info.UserEntity.USERNAME;           

        }




        /// <summary>
        /// 生成查询条件字符串
        /// </summary>
        private StringBuilder GenerationRepairCaseSQLString()
        {
            StringBuilder sql = new StringBuilder();
            #region MyRegion
            //if (!String.IsNullOrEmpty(Request.QueryString["CASEID"]))
            //{
            //    sql.Append(" and CASEID like '%" + Request.QueryString["CASEID"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLER"]))
            //{
            //    sql.Append(" and CALLER like '%" + Request.QueryString["CALLER"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLED"]))
            //{
            //    sql.Append(" and CALLED like '%" + Request.QueryString["CALLED"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLID"]))
            //{
            //    sql.Append(" and CALLID = '" + Request.QueryString["CALLID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RECORDCODE"]))
            //{
            //    sql.Append(" and RECORDCODE like '%" + Request.QueryString["RECORDCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLTYPE"]))
            //{
            //    sql.Append(" and CALLTYPE like '%" + Request.QueryString["CALLTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERID"]))
            //{
            //    sql.Append(" and CUSTOMERID = '" + Request.QueryString["CUSTOMERID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERNAME"]))
            //{
            //    sql.Append(" and CUSTOMERNAME like '%" + Request.QueryString["CUSTOMERNAME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COUNTRY"]))
            //{
            //    sql.Append(" and COUNTRY like '%" + Request.QueryString["COUNTRY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PROVINCE"]))
            //{
            //    sql.Append(" and PROVINCE like '%" + Request.QueryString["PROVINCE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PREFECTURECITY"]))
            //{
            //    sql.Append(" and PREFECTURECITY like '%" + Request.QueryString["PREFECTURECITY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CITY"]))
            //{
            //    sql.Append(" and CITY like '%" + Request.QueryString["CITY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VILLAGETOWN"]))
            //{
            //    sql.Append(" and VILLAGETOWN like '%" + Request.QueryString["VILLAGETOWN"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VILLAGE"]))
            //{
            //    sql.Append(" and VILLAGE like '%" + Request.QueryString["VILLAGE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["GROUPTEAM"]))
            //{
            //    sql.Append(" and GROUPTEAM like '%" + Request.QueryString["GROUPTEAM"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ADDRESS"]))
            //{
            //    sql.Append(" and ADDRESS like '%" + Request.QueryString["ADDRESS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FIRSTCONTACTTEL"]))
            //{
            //    sql.Append(" and FIRSTCONTACTTEL like '%" + Request.QueryString["FIRSTCONTACTTEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BRAND"]))
            //{
            //    sql.Append(" and BRAND like '%" + Request.QueryString["BRAND"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VEHICLETYPE"]))
            //{
            //    sql.Append(" and VEHICLETYPE like '%" + Request.QueryString["VEHICLETYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VINCODE"]))
            //{
            //    sql.Append(" and VINCODE like '%" + Request.QueryString["VINCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTCODE"]))
            //{
            //    sql.Append(" and PRODUCTCODE like '%" + Request.QueryString["PRODUCTCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERIES"]))
            //{
            //    sql.Append(" and SERIES like '%" + Request.QueryString["SERIES"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MODELS"]))
            //{
            //    sql.Append(" and MODELS like '%" + Request.QueryString["MODELS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ENGINEMODEL"]))
            //{
            //    sql.Append(" and ENGINEMODEL like '%" + Request.QueryString["ENGINEMODEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ENGINEMANUFACTURERS"]))
            //{
            //    sql.Append(" and ENGINEMANUFACTURERS like '%" + Request.QueryString["ENGINEMANUFACTURERS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FAULTSYSTEM"]))
            //{
            //    sql.Append(" and FAULTSYSTEM like '%" + Request.QueryString["FAULTSYSTEM"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FAILEDPARTSASSEMBLY"]))
            //{
            //    sql.Append(" and FAILEDPARTSASSEMBLY like '%" + Request.QueryString["FAILEDPARTSASSEMBLY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FAILUREPARTS"]))
            //{
            //    sql.Append(" and FAILUREPARTS like '%" + Request.QueryString["FAILUREPARTS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FAULTCODES"]))
            //{
            //    sql.Append(" and FAULTCODES like '%" + Request.QueryString["FAULTCODES"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SYMPTOM"]))
            //{
            //    sql.Append(" and SYMPTOM like '%" + Request.QueryString["SYMPTOM"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SYMPTOMDESCRIPTION"]))
            //{
            //    sql.Append(" and SYMPTOMDESCRIPTION like '%" + Request.QueryString["SYMPTOMDESCRIPTION"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FAILURELEVEL"]))
            //{
            //    sql.Append(" and FAILURELEVEL like '%" + Request.QueryString["FAILURELEVEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FAILUREANALYSIS"]))
            //{
            //    sql.Append(" and FAILUREANALYSIS like '%" + Request.QueryString["FAILUREANALYSIS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["STATUS"]))
            //{
            //    sql.Append(" and STATUS like '%" + Request.QueryString["STATUS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["HANDLING"]))
            //{
            //    sql.Append(" and HANDLING like '%" + Request.QueryString["HANDLING"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["APPROACH"]))
            //{
            //    sql.Append(" and APPROACH like '%" + Request.QueryString["APPROACH"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RESULTS"]))
            //{
            //    sql.Append(" and RESULTS like '%" + Request.QueryString["RESULTS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SEATSSUMMARY"]))
            //{
            //    sql.Append(" and SEATSSUMMARY like '%" + Request.QueryString["SEATSSUMMARY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FAILUREOCCURS"]))
            //{
            //    sql.Append(" and FAILUREOCCURS like '%" + Request.QueryString["FAILUREOCCURS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["GPSADDRESS"]))
            //{
            //    sql.Append(" and GPSADDRESS like '%" + Request.QueryString["GPSADDRESS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEBegin"]))
            //{
            //    sql.Append(" and CREATETIME >= '" + Request.QueryString["CREATETIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEEnd"]))
            //{
            //    sql.Append(" and CREATETIME < '" + Request.QueryString["CREATETIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLEID"]))
            //{
            //    sql.Append(" and CREATEPEOPLEID = '" + Request.QueryString["CREATEPEOPLEID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLE"]))
            //{
            //    sql.Append(" and CREATEPEOPLE like '%" + Request.QueryString["CREATEPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLEID"]))
            //{
            //    sql.Append(" and LASTMODIFYPEOPLEID = '" + Request.QueryString["LASTMODIFYPEOPLEID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLE"]))
            //{
            //    sql.Append(" and LASTMODIFYPEOPLE like '%" + Request.QueryString["LASTMODIFYPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REMARK"]))
            //{
            //    sql.Append(" and REMARK like '%" + Request.QueryString["REMARK"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MARKETDEPARTMENTID"]))
            //{
            //    sql.Append(" and MARKETDEPARTMENTID = '" + Request.QueryString["MARKETDEPARTMENTID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MARKETDEPARTMENTCODE"]))
            //{
            //    sql.Append(" and MARKETDEPARTMENTCODE like '%" + Request.QueryString["MARKETDEPARTMENTCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MARKETDEPARTMENTNAME"]))
            //{
            //    sql.Append(" and MARKETDEPARTMENTNAME like '%" + Request.QueryString["MARKETDEPARTMENTNAME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DISPATCHINGOBJECTTYPE"]))
            //{
            //    sql.Append(" and DISPATCHINGOBJECTTYPE like '%" + Request.QueryString["DISPATCHINGOBJECTTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DISPATCHINGOBJECT"]))
            //{
            //    sql.Append(" and DISPATCHINGOBJECT like '%" + Request.QueryString["DISPATCHINGOBJECT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DISPATCHINGTIMEBegin"]))
            //{
            //    sql.Append(" and DISPATCHINGTIME >= '" + Request.QueryString["DISPATCHINGTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DISPATCHINGTIMEEnd"]))
            //{
            //    sql.Append(" and DISPATCHINGTIME < '" + Request.QueryString["DISPATCHINGTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FOLLOWUPTIMEBegin"]))
            //{
            //    sql.Append(" and FOLLOWUPTIME >= '" + Request.QueryString["FOLLOWUPTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FOLLOWUPTIMEEnd"]))
            //{
            //    sql.Append(" and FOLLOWUPTIME < '" + Request.QueryString["FOLLOWUPTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FOLLOWUPCONTENT"]))
            //{
            //    sql.Append(" and FOLLOWUPCONTENT like '%" + Request.QueryString["FOLLOWUPCONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PROCESSINGTIMEBegin"]))
            //{
            //    sql.Append(" and PROCESSINGTIME >= '" + Request.QueryString["PROCESSINGTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PROCESSINGTIMEEnd"]))
            //{
            //    sql.Append(" and PROCESSINGTIME < '" + Request.QueryString["PROCESSINGTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PROCESSINGCONTENT"]))
            //{
            //    sql.Append(" and PROCESSINGCONTENT like '%" + Request.QueryString["PROCESSINGCONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CLOSETIMEBegin"]))
            //{
            //    sql.Append(" and CLOSETIME >= '" + Request.QueryString["CLOSETIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CLOSETIMEEnd"]))
            //{
            //    sql.Append(" and CLOSETIME < '" + Request.QueryString["CLOSETIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CLOSECONTENT"]))
            //{
            //    sql.Append(" and CLOSECONTENT like '%" + Request.QueryString["CLOSECONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["TURNTIMEBegin"]))
            //{
            //    sql.Append(" and TURNTIME >= '" + Request.QueryString["TURNTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["TURNTIMEEnd"]))
            //{
            //    sql.Append(" and TURNTIME < '" + Request.QueryString["TURNTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["TURNCONTENT"]))
            //{
            //    sql.Append(" and TURNCONTENT like '%" + Request.QueryString["TURNCONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["TODOREMINDERTIMEBegin"]))
            //{
            //    sql.Append(" and TODOREMINDERTIME >= '" + Request.QueryString["TODOREMINDERTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["TODOREMINDERTIMEEnd"]))
            //{
            //    sql.Append(" and TODOREMINDERTIME < '" + Request.QueryString["TODOREMINDERTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REVISITINGTIMEBegin"]))
            //{
            //    sql.Append(" and REVISITINGTIME >= '" + Request.QueryString["REVISITINGTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REVISITINGTIMEEnd"]))
            //{
            //    sql.Append(" and REVISITINGTIME < '" + Request.QueryString["REVISITINGTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RECEIVETIMEBegin"]))
            //{
            //    sql.Append(" and RECEIVETIME >= '" + Request.QueryString["RECEIVETIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RECEIVETIMEEnd"]))
            //{
            //    sql.Append(" and RECEIVETIME < '" + Request.QueryString["RECEIVETIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RECEIVECONTENT"]))
            //{
            //    sql.Append(" and RECEIVECONTENT like '%" + Request.QueryString["RECEIVECONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RECEIVEPEOPLE"]))
            //{
            //    sql.Append(" and RECEIVEPEOPLE like '%" + Request.QueryString["RECEIVEPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DEPARTURETIMEBegin"]))
            //{
            //    sql.Append(" and DEPARTURETIME >= '" + Request.QueryString["DEPARTURETIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DEPARTURETIMEEnd"]))
            //{
            //    sql.Append(" and DEPARTURETIME < '" + Request.QueryString["DEPARTURETIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DEPARTURECONTENT"]))
            //{
            //    sql.Append(" and DEPARTURECONTENT like '%" + Request.QueryString["DEPARTURECONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["DEPARTUREPEOPLE"]))
            //{
            //    sql.Append(" and DEPARTUREPEOPLE like '%" + Request.QueryString["DEPARTUREPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ARRIVALTIMEBegin"]))
            //{
            //    sql.Append(" and ARRIVALTIME >= '" + Request.QueryString["ARRIVALTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ARRIVALTIMEEnd"]))
            //{
            //    sql.Append(" and ARRIVALTIME < '" + Request.QueryString["ARRIVALTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ARRIVALCONTENT"]))
            //{
            //    sql.Append(" and ARRIVALCONTENT like '%" + Request.QueryString["ARRIVALCONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ARRIVALPEOPLE"]))
            //{
            //    sql.Append(" and ARRIVALPEOPLE like '%" + Request.QueryString["ARRIVALPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLETEDTIMEBegin"]))
            //{
            //    sql.Append(" and COMPLETEDTIME >= '" + Request.QueryString["COMPLETEDTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLETEDTIMEEnd"]))
            //{
            //    sql.Append(" and COMPLETEDTIME < '" + Request.QueryString["COMPLETEDTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLETEDCONTENT"]))
            //{
            //    sql.Append(" and COMPLETEDCONTENT like '%" + Request.QueryString["COMPLETEDCONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLETEDPEOPLE"]))
            //{
            //    sql.Append(" and COMPLETEDPEOPLE like '%" + Request.QueryString["COMPLETEDPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICENUMBER"]))
            //{
            //    sql.Append(" and SERVICENUMBER like '%" + Request.QueryString["SERVICENUMBER"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MILEAGE"]))
            //{
            //    sql.Append(" and MILEAGE like '%" + Request.QueryString["MILEAGE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PLACEMETHOD"]))
            //{
            //    sql.Append(" and PLACEMETHOD like '%" + Request.QueryString["PLACEMETHOD"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICEFEE"]))
            //{
            //    sql.Append(" and SERVICEFEE like '%" + Request.QueryString["SERVICEFEE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICEHOURS"]))
            //{
            //    sql.Append(" and SERVICEHOURS like '%" + Request.QueryString["SERVICEHOURS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REPAIRPARTS"]))
            //{
            //    sql.Append(" and REPAIRPARTS like '%" + Request.QueryString["REPAIRPARTS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["HANDLINGINSTRUCTIONS"]))
            //{
            //    sql.Append(" and HANDLINGINSTRUCTIONS like '%" + Request.QueryString["HANDLINGINSTRUCTIONS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTSATISFACTION"]))
            //{
            //    sql.Append(" and PRODUCTSATISFACTION like '%" + Request.QueryString["PRODUCTSATISFACTION"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICESATISFACTION"]))
            //{
            //    sql.Append(" and SERVICESATISFACTION like '%" + Request.QueryString["SERVICESATISFACTION"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITTIMEBegin"]))
            //{
            //    sql.Append(" and VISITTIME >= '" + Request.QueryString["VISITTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITTIMEEnd"]))
            //{
            //    sql.Append(" and VISITTIME < '" + Request.QueryString["VISITTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITCOMPLETEDTIMEBegin"]))
            //{
            //    sql.Append(" and VISITCOMPLETEDTIME >= '" + Request.QueryString["VISITCOMPLETEDTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITCOMPLETEDTIMEEnd"]))
            //{
            //    sql.Append(" and VISITCOMPLETEDTIME < '" + Request.QueryString["VISITCOMPLETEDTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITREMARK"]))
            //{
            //    sql.Append(" and VISITREMARK like '%" + Request.QueryString["VISITREMARK"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONID"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONID = '" + Request.QueryString["BUSINESSDIVISIONID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONNAME"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONNAME like '%" + Request.QueryString["BUSINESSDIVISIONNAME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONCODE"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONCODE like '%" + Request.QueryString["BUSINESSDIVISIONCODE"] + "%'");
            //} 
            #endregion

            #region 权限部分
            if (!UserLoginInfo.IsAdministrator())
            {
                //操作员当前事业务数据
                sql.Append(" and BUSINESSDIVISIONCODE = '" + _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE.Trim() + "'");

                //操作员有权看到人员的数据
                switch ((UserType)Enum.Parse(typeof(UserType), _userLoginInfo.UserEntity.USERTYPE.Trim()))
                {
                    case UserType.中心部门:
                        {
                            DepartmentType departmentType = (DepartmentType)Enum.Parse(typeof(DepartmentType), _userLoginInfo.DepartmentEntity.ISCENTER.ToString());
                            if (departmentType == DepartmentType.服务部门)
                            {
                                sql.Append(String.Format(" and ProcessingObjectType = '{0}' ", _userLoginInfo.UserEntity.USERTYPE.Trim()));
                                sql.Append(String.Format(" and ProcessingDepartmentID = '{0}' ", _userLoginInfo.UserEntity.DEPARTMENTID));
                                sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "ProcessingUserID", true));

                            }
                            else
                            {
                                sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "CREATEPEOPLEID", "HELPUSERID"));
                            }


                        }
                        break;
                    case UserType.供应商:
                    case UserType.市场部:
                    case UserType.服务商:
                    case UserType.经销商:
                        {
                            sql.Append(String.Format(" and ProcessingObjectType = '{0}' ", _userLoginInfo.UserEntity.USERTYPE.Trim()));
                            sql.Append(String.Format(" and ProcessingDepartmentID = '{0}' ", _userLoginInfo.UserEntity.DEPARTMENTID));
                            sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "ProcessingUserID", true));
                        }
                        break;
                }


                //操作员角色需待办数据 及 超期数据
                sql.Append(roleOrderStatusAuthorityBll.GenerateStatusAuthorityConditions(_userLoginInfo,
                                                                                         WorkOrderType.报修工单, "STATUS"));
            }
            #endregion

            return sql;

        }

        /// <summary>
        /// 生成查询条件字符串
        /// </summary>
        private StringBuilder GenerationConsultingCaseSQLString()
        {
            StringBuilder sql = new StringBuilder();
            #region MyRegion
            //if (!String.IsNullOrEmpty(Request.QueryString["CASEID"]))
            //{
            //    sql.Append(" and CASEID like '%" + Request.QueryString["CASEID"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLER"]))
            //{
            //    sql.Append(" and CALLER like '%" + Request.QueryString["CALLER"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLED"]))
            //{
            //    sql.Append(" and CALLED like '%" + Request.QueryString["CALLED"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLID"]))
            //{
            //    sql.Append(" and CALLID = '" + Request.QueryString["CALLID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RECORDCODE"]))
            //{
            //    sql.Append(" and RECORDCODE like '%" + Request.QueryString["RECORDCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLTYPE"]))
            //{
            //    sql.Append(" and CALLTYPE like '%" + Request.QueryString["CALLTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERID"]))
            //{
            //    sql.Append(" and CUSTOMERID = '" + Request.QueryString["CUSTOMERID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERNAME"]))
            //{
            //    sql.Append(" and CUSTOMERNAME like '%" + Request.QueryString["CUSTOMERNAME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FIRSTCONTACTTEL"]))
            //{
            //    sql.Append(" and FIRSTCONTACTTEL like '%" + Request.QueryString["FIRSTCONTACTTEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ADDRESS"]))
            //{
            //    sql.Append(" and ADDRESS like '%" + Request.QueryString["ADDRESS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COUNTRY"]))
            //{
            //    sql.Append(" and COUNTRY like '%" + Request.QueryString["COUNTRY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PROVINCE"]))
            //{
            //    sql.Append(" and PROVINCE like '%" + Request.QueryString["PROVINCE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PREFECTURECITY"]))
            //{
            //    sql.Append(" and PREFECTURECITY like '%" + Request.QueryString["PREFECTURECITY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CITY"]))
            //{
            //    sql.Append(" and CITY like '%" + Request.QueryString["CITY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VILLAGETOWN"]))
            //{
            //    sql.Append(" and VILLAGETOWN like '%" + Request.QueryString["VILLAGETOWN"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VILLAGE"]))
            //{
            //    sql.Append(" and VILLAGE like '%" + Request.QueryString["VILLAGE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["GROUPTEAM"]))
            //{
            //    sql.Append(" and GROUPTEAM like '%" + Request.QueryString["GROUPTEAM"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CONSULTINGTYPE"]))
            //{
            //    sql.Append(" and CONSULTINGTYPE like '%" + Request.QueryString["CONSULTINGTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VINCODE"]))
            //{
            //    sql.Append(" and VINCODE like '%" + Request.QueryString["VINCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BRAND"]))
            //{
            //    sql.Append(" and BRAND like '%" + Request.QueryString["BRAND"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VEHICLETYPE"]))
            //{
            //    sql.Append(" and VEHICLETYPE like '%" + Request.QueryString["VEHICLETYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTCODE"]))
            //{
            //    sql.Append(" and PRODUCTCODE like '%" + Request.QueryString["PRODUCTCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERIES"]))
            //{
            //    sql.Append(" and SERIES like '%" + Request.QueryString["SERIES"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MODELS"]))
            //{
            //    sql.Append(" and MODELS like '%" + Request.QueryString["MODELS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ENGINEMODEL"]))
            //{
            //    sql.Append(" and ENGINEMODEL like '%" + Request.QueryString["ENGINEMODEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ENGINEMANUFACTURERS"]))
            //{
            //    sql.Append(" and ENGINEMANUFACTURERS like '%" + Request.QueryString["ENGINEMANUFACTURERS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CONSULTINGCONTENT"]))
            //{
            //    sql.Append(" and CONSULTINGCONTENT like '%" + Request.QueryString["CONSULTINGCONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["APPROACH"]))
            //{
            //    sql.Append(" and APPROACH like '%" + Request.QueryString["APPROACH"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["STATUS"]))
            //{
            //    sql.Append(" and STATUS like '%" + Request.QueryString["STATUS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RESULTS"]))
            //{
            //    sql.Append(" and RESULTS like '%" + Request.QueryString["RESULTS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REMINDERTIME"]))
            //{
            //    sql.Append(" and REMINDERTIME like '%" + Request.QueryString["REMINDERTIME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEBegin"]))
            //{
            //    sql.Append(" and CREATETIME >= '" + Request.QueryString["CREATETIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEEnd"]))
            //{
            //    sql.Append(" and CREATETIME < '" + Request.QueryString["CREATETIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLEID"]))
            //{
            //    sql.Append(" and CREATEPEOPLEID = '" + Request.QueryString["CREATEPEOPLEID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLE"]))
            //{
            //    sql.Append(" and CREATEPEOPLE like '%" + Request.QueryString["CREATEPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLEID"]))
            //{
            //    sql.Append(" and LASTMODIFYPEOPLEID = '" + Request.QueryString["LASTMODIFYPEOPLEID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLE"]))
            //{
            //    sql.Append(" and LASTMODIFYPEOPLE like '%" + Request.QueryString["LASTMODIFYPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REMARK"]))
            //{
            //    sql.Append(" and REMARK like '%" + Request.QueryString["REMARK"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONID"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONID = '" + Request.QueryString["BUSINESSDIVISIONID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONNAME"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONNAME like '%" + Request.QueryString["BUSINESSDIVISIONNAME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONCODE"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONCODE like '%" + Request.QueryString["BUSINESSDIVISIONCODE"] + "%'");
            //} 
            #endregion

            if (!UserLoginInfo.IsAdministrator())
            {
                //操作员当前事业务数据
                sql.Append(" and BUSINESSDIVISIONCODE = '" + _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE.Trim() + "'");

                //操作员有权看到人员的数据
                sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "CREATEPEOPLEID"));

                //操作员角色需待办数据 及 超期数据
                sql.Append(roleOrderStatusAuthorityBll.GenerateStatusAuthorityConditions(_userLoginInfo,
                                                                                         WorkOrderType.咨询工单, "STATUS"));

            }
            return sql;

        }

        /// <summary>
        /// 生成查询条件字符串
        /// </summary>
        private StringBuilder GenerationComplaintCaseSQLString()
        {
            StringBuilder sql = new StringBuilder();
            #region MyRegion
            //if (!String.IsNullOrEmpty(Request.QueryString["CASEID"]))
            //{
            //    sql.Append(" and CASEID like '%" + Request.QueryString["CASEID"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLER"]))
            //{
            //    sql.Append(" and CALLER like '%" + Request.QueryString["CALLER"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLED"]))
            //{
            //    sql.Append(" and CALLED like '%" + Request.QueryString["CALLED"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLID"]))
            //{
            //    sql.Append(" and CALLID = '" + Request.QueryString["CALLID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RECORDCODE"]))
            //{
            //    sql.Append(" and RECORDCODE like '%" + Request.QueryString["RECORDCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CALLTYPE"]))
            //{
            //    sql.Append(" and CALLTYPE like '%" + Request.QueryString["CALLTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERID"]))
            //{
            //    sql.Append(" and CUSTOMERID = '" + Request.QueryString["CUSTOMERID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CUSTOMERNAME"]))
            //{
            //    sql.Append(" and CUSTOMERNAME like '%" + Request.QueryString["CUSTOMERNAME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["FIRSTCONTACTTEL"]))
            //{
            //    sql.Append(" and FIRSTCONTACTTEL like '%" + Request.QueryString["FIRSTCONTACTTEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ADDRESS"]))
            //{
            //    sql.Append(" and ADDRESS like '%" + Request.QueryString["ADDRESS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COUNTRY"]))
            //{
            //    sql.Append(" and COUNTRY like '%" + Request.QueryString["COUNTRY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PROVINCE"]))
            //{
            //    sql.Append(" and PROVINCE like '%" + Request.QueryString["PROVINCE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PREFECTURECITY"]))
            //{
            //    sql.Append(" and PREFECTURECITY like '%" + Request.QueryString["PREFECTURECITY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CITY"]))
            //{
            //    sql.Append(" and CITY like '%" + Request.QueryString["CITY"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VILLAGETOWN"]))
            //{
            //    sql.Append(" and VILLAGETOWN like '%" + Request.QueryString["VILLAGETOWN"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VILLAGE"]))
            //{
            //    sql.Append(" and VILLAGE like '%" + Request.QueryString["VILLAGE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["GROUPTEAM"]))
            //{
            //    sql.Append(" and GROUPTEAM like '%" + Request.QueryString["GROUPTEAM"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VEHICLELOCATION"]))
            //{
            //    sql.Append(" and VEHICLELOCATION like '%" + Request.QueryString["VEHICLELOCATION"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["GPSADDRESS"]))
            //{
            //    sql.Append(" and GPSADDRESS like '%" + Request.QueryString["GPSADDRESS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CONSULTINGTYPE"]))
            //{
            //    sql.Append(" and CONSULTINGTYPE like '%" + Request.QueryString["CONSULTINGTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VINCODE"]))
            //{
            //    sql.Append(" and VINCODE like '%" + Request.QueryString["VINCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BRAND"]))
            //{
            //    sql.Append(" and BRAND like '%" + Request.QueryString["BRAND"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VEHICLETYPE"]))
            //{
            //    sql.Append(" and VEHICLETYPE like '%" + Request.QueryString["VEHICLETYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTCODE"]))
            //{
            //    sql.Append(" and PRODUCTCODE like '%" + Request.QueryString["PRODUCTCODE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERIES"]))
            //{
            //    sql.Append(" and SERIES like '%" + Request.QueryString["SERIES"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MODELS"]))
            //{
            //    sql.Append(" and MODELS like '%" + Request.QueryString["MODELS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ENGINEMODEL"]))
            //{
            //    sql.Append(" and ENGINEMODEL like '%" + Request.QueryString["ENGINEMODEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["ENGINEMANUFACTURERS"]))
            //{
            //    sql.Append(" and ENGINEMANUFACTURERS like '%" + Request.QueryString["ENGINEMANUFACTURERS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["OBJECTTYPE"]))
            //{
            //    sql.Append(" and OBJECTTYPE like '%" + Request.QueryString["OBJECTTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLAINTOBJECT"]))
            //{
            //    sql.Append(" and COMPLAINTOBJECT like '%" + Request.QueryString["COMPLAINTOBJECT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLAINTTYPE"]))
            //{
            //    sql.Append(" and COMPLAINTTYPE like '%" + Request.QueryString["COMPLAINTTYPE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLAINTCONTENT"]))
            //{
            //    sql.Append(" and COMPLAINTCONTENT like '%" + Request.QueryString["COMPLAINTCONTENT"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["COMPLAINTLEVEL"]))
            //{
            //    sql.Append(" and COMPLAINTLEVEL like '%" + Request.QueryString["COMPLAINTLEVEL"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["APPROACH"]))
            //{
            //    sql.Append(" and APPROACH like '%" + Request.QueryString["APPROACH"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["HANDLING"]))
            //{
            //    sql.Append(" and HANDLING like '%" + Request.QueryString["HANDLING"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["STATUS"]))
            //{
            //    sql.Append(" and STATUS like '%" + Request.QueryString["STATUS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["RESULTS"]))
            //{
            //    sql.Append(" and RESULTS like '%" + Request.QueryString["RESULTS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEBegin"]))
            //{
            //    sql.Append(" and CREATETIME >= '" + Request.QueryString["CREATETIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATETIMEEnd"]))
            //{
            //    sql.Append(" and CREATETIME < '" + Request.QueryString["CREATETIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLEID"]))
            //{
            //    sql.Append(" and CREATEPEOPLEID = '" + Request.QueryString["CREATEPEOPLEID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["CREATEPEOPLE"]))
            //{
            //    sql.Append(" and CREATEPEOPLE like '%" + Request.QueryString["CREATEPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLEID"]))
            //{
            //    sql.Append(" and LASTMODIFYPEOPLEID = '" + Request.QueryString["LASTMODIFYPEOPLEID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["LASTMODIFYPEOPLE"]))
            //{
            //    sql.Append(" and LASTMODIFYPEOPLE like '%" + Request.QueryString["LASTMODIFYPEOPLE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REMARK"]))
            //{
            //    sql.Append(" and REMARK like '%" + Request.QueryString["REMARK"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICENUMBER"]))
            //{
            //    sql.Append(" and SERVICENUMBER like '%" + Request.QueryString["SERVICENUMBER"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["MILEAGE"]))
            //{
            //    sql.Append(" and MILEAGE like '%" + Request.QueryString["MILEAGE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PLACEMETHOD"]))
            //{
            //    sql.Append(" and PLACEMETHOD like '%" + Request.QueryString["PLACEMETHOD"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICEFEE"]))
            //{
            //    sql.Append(" and SERVICEFEE like '%" + Request.QueryString["SERVICEFEE"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICEHOURS"]))
            //{
            //    sql.Append(" and SERVICEHOURS like '%" + Request.QueryString["SERVICEHOURS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["REPAIRPARTS"]))
            //{
            //    sql.Append(" and REPAIRPARTS like '%" + Request.QueryString["REPAIRPARTS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["HANDLINGINSTRUCTIONS"]))
            //{
            //    sql.Append(" and HANDLINGINSTRUCTIONS like '%" + Request.QueryString["HANDLINGINSTRUCTIONS"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["PRODUCTSATISFACTION"]))
            //{
            //    sql.Append(" and PRODUCTSATISFACTION like '%" + Request.QueryString["PRODUCTSATISFACTION"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["SERVICESATISFACTION"]))
            //{
            //    sql.Append(" and SERVICESATISFACTION like '%" + Request.QueryString["SERVICESATISFACTION"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITTIMEBegin"]))
            //{
            //    sql.Append(" and VISITTIME >= '" + Request.QueryString["VISITTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITTIMEEnd"]))
            //{
            //    sql.Append(" and VISITTIME < '" + Request.QueryString["VISITTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITCOMPLETEDTIMEBegin"]))
            //{
            //    sql.Append(" and VISITCOMPLETEDTIME >= '" + Request.QueryString["VISITCOMPLETEDTIMEBegin"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITCOMPLETEDTIMEEnd"]))
            //{
            //    sql.Append(" and VISITCOMPLETEDTIME < '" + Request.QueryString["VISITCOMPLETEDTIMEEnd"].Trim() + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["VISITREMARK"]))
            //{
            //    sql.Append(" and VISITREMARK like '%" + Request.QueryString["VISITREMARK"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONID"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONID = '" + Request.QueryString["BUSINESSDIVISIONID"] + "'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONNAME"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONNAME like '%" + Request.QueryString["BUSINESSDIVISIONNAME"] + "%'");
            //}
            //if (!String.IsNullOrEmpty(Request.QueryString["BUSINESSDIVISIONCODE"]))
            //{
            //    sql.Append(" and BUSINESSDIVISIONCODE like '%" + Request.QueryString["BUSINESSDIVISIONCODE"] + "%'");
            //} 
            #endregion



            #region 权限部分
            if (!UserLoginInfo.IsAdministrator())
            {
                //操作员当前事业务数据
                sql.Append(" and BUSINESSDIVISIONCODE = '" + _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE.Trim() + "'");

                //操作员有权看到人员的数据
                switch ((UserType)Enum.Parse(typeof(UserType), _userLoginInfo.UserEntity.USERTYPE.Trim()))
                {
                    case UserType.中心部门:
                        {
                            DepartmentType departmentType = (DepartmentType)Enum.Parse(typeof(DepartmentType), _userLoginInfo.DepartmentEntity.ISCENTER.ToString());
                            if (departmentType == DepartmentType.服务部门)
                            {
                                sql.Append(String.Format(" and ProcessingObjectType = '{0}' ", _userLoginInfo.UserEntity.USERTYPE.Trim()));
                                sql.Append(String.Format(" and ProcessingDepartmentID = '{0}' ", _userLoginInfo.UserEntity.DEPARTMENTID));
                                sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "ProcessingUserID", true));

                            }
                            else
                            {
                                //操作员有权看到人员的数据
                                sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "CREATEPEOPLEID", "HELPUSERID"));
                            }


                        }
                        break;
                    case UserType.供应商:
                    case UserType.市场部:
                    case UserType.服务商:
                    case UserType.经销商:
                        {
                            sql.Append(String.Format(" and ProcessingObjectType = '{0}' ", _userLoginInfo.UserEntity.USERTYPE.Trim()));
                            sql.Append(String.Format(" and ProcessingDepartmentID = '{0}' ", _userLoginInfo.UserEntity.DEPARTMENTID));
                            sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "ProcessingUserID", true));
                        }
                        break;
                }

                //操作员角色需待办数据 及 超期数据
                sql.Append(roleOrderStatusAuthorityBll.GenerateStatusAuthorityConditions(_userLoginInfo,
                                                                                         WorkOrderType.投诉工单, "STATUS"));



            }
            #endregion


            return sql;

        }

        /// <summary>
        /// 生成查询条件字符串
        /// </summary>
        private StringBuilder GenerationVoiceMailSQLString()
        {
            StringBuilder sql = new StringBuilder();


            #region 权限部分
            if (!UserLoginInfo.IsAdministrator())
            {
                //操作员当前事业务数据
                sql.Append(" and BUSINESSDIVISIONCODE = '" + _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE.Trim() + "'");

                //操作员有权看到人员的数据
                sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "AssignedPersonID"));

                //
                sql.Append(String.Format(" and STATUS in ({0}) ", ((int)VoiceStatus.待回电).ToString() + "," + ((int)VoiceStatus.未接通).ToString()));
            }
            #endregion

            return sql;

        }

        /// <summary>
        /// 生成查询条件字符串
        /// </summary>
        private StringBuilder GenerationLostCallSQLString()
        {
            StringBuilder sql = new StringBuilder();

            if (!UserLoginInfo.IsAdministrator())
            {
                //操作员当前事业务数据
                sql.Append(" and BUSINESSDIVISIONCODE = '" + _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE.Trim() + "'");

                //操作员有权看到人员的数据
                sql.Append(caBll.GenerateContentAuthorityConditions(_userLoginInfo, "AssignedPersonID"));

                //
                sql.Append(String.Format(" and STATUS in ({0}) ", ((int)LostStatus.待回电).ToString() + "," + ((int)LostStatus.未接通).ToString()));

            }
            return sql;

        }


    }
}
